package com.adminsystem.service.impl;

import com.adminsystem.entity.custom.EchartsBean;
import com.adminsystem.service.AppMapService;
import okhttp3.OkHttpClient;
import okhttp3.ResponseBody;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;

@Service
public class AppMapServiceImpl implements AppMapService {
    private final OkHttpClient okHttpClient;

    @Autowired
    public AppMapServiceImpl(OkHttpClient okHttpClient) {
        this.okHttpClient = okHttpClient;
    }

    @Override
    public ResponseBody getMapData(EchartsBean echartsBean) throws IOException {
        okhttp3.Request request = new okhttp3.Request.Builder()
                .url(echartsBean.getUrl())
                .build();

        okhttp3.Response response = okHttpClient.newCall(request).execute();
        System.out.println("response:"+response.body().toString());
        return response.body();
    }

}
